# -*- coding:utf-8 -*-
# 接口端，通过http接收传入的数据
import sqlite3
import json
import time
from flask import Flask, request, render_template
import redis

app = Flask(__name__)

key = 'test'
rds = redis.StrictRedis(host='localhost', port=6379, db=0)

@app.route("/", methods=["GET", 'POST'])
def put_in():
    print("In put_in")
    # 默认返回内容
    return_dict = {'return_code': '200', 'errcode': '成功', 'result': True}
    print('请求方式为------->', request.method)
    # get_data = request.get_data()
    # print(get_data)
    rds.set(rds.incr(key, 1), time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
    return json.dumps(return_dict, ensure_ascii=True)

if __name__ == "__main__":
    app.run(host = "0.0.0.0",port=5010,debug=False)
    # app.run(host = "0.0.0.0",port=10000,debug=False)
    # 重置计数器为0
    rds.getset(key, 0)